package com.rightsidetech.http.controller.agentApp.material;

import com.github.pagehelper.PageInfo;
import com.rightsidetech.commom.base.PageRequest;
import com.rightsidetech.commom.base.ResponseData;
import com.rightsidetech.commom.enums.CodeIdEnum;
import com.rightsidetech.commom.utils.BeanValidator;
import com.rightsidetech.http.aspect.Log;
import com.rightsidetech.http.aspect.Token;
import com.rightsidetech.http.base.BaseController;
import com.rightsidetech.system.dtos.response.material.ActivityFileResp;
import com.rightsidetech.system.dtos.response.material.ActivityMaterialAppResp;
import com.rightsidetech.system.service.SysMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.ConstraintViolation;
import java.util.List;

/**
 * @Package: com.rightsidetech.http.controller.admin.material
 * @ClassName: ActivityMaterialController
 * @Author: yinj
 * @CreateTime: 2021/12/17 9:44
 * @Description: 活动素材相关
 */
@RestController
@Api(tags = "代理商-素材管理相关api")
@RequestMapping("/agentApp/material")
@ShenyuSpringMvcClient(path = "/agentApp/material/**")
public class ActivityMaterialAgentAppController extends BaseController {

    @Resource
    private SysMaterialService sysActivityMaterialService;


    @Log
    @GetMapping("/page")
    @Token
    @ApiOperation("素材列表")
    public ResponseData<PageInfo<ActivityMaterialAppResp>> page(PageRequest request) throws Exception{
        ConstraintViolation validate = BeanValidator.validate(request);
        if (validate != null) {
            return new ResponseData<>(CodeIdEnum.ParameterMalformed.getValue(), validate.getMessage());
        }
        return sysActivityMaterialService.agentAppPage(request, (byte) 1);
    }



    @Log
    @GetMapping("/file_details")
    @Token
    @ApiOperation("文件详情")
    public ResponseData<List<ActivityFileResp>> details(Long id) throws Exception{
        return sysActivityMaterialService.fileDetails(id);
    }


}
